package com.bw.zhuangao5___day002.Fragment.Home.Fragment2;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * create by ertu
 * create on 2021/9/22
 * description
 */
public class MainOkhttps {
    public static MainOkhttps okhttps;

    public static Retrofit retrofit;
    public static MainOkhttps getOkhttpboos(){
        if (okhttps==null) {
            synchronized (MainOkhttps.class)
            {
                if (okhttps==null)
                {
                    okhttps =new MainOkhttps();
                }
            }

        }
        return okhttps;
    }

    public Retrofit retrofit() {
        if (retrofit ==null){
            synchronized (Retrofit.class){
                if (retrofit==null)
                {
                    retrofit =new Retrofit.Builder().baseUrl("http://service.picasso.adesk.com/")
                            .client(new OkHttpClient.Builder()
                                    .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                                    .build())
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .addConverterFactory(GsonConverterFactory.create())
                            .build();
                }
            }
        }

        return retrofit;
    }
}
